home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************************
- ********************************************************************************
- ********************************************************************************
-
- PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
- THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
-
- P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
-
-
- ********************************************************************************
- ********************************************************************************
- *******************************************************************************/
- #include "header.h"
-
- /*******************USEFUL ROUTINES FOR LOW LEVEL I/O**************************/
-
- getbuf(cp,ptrnoofchars)
- register struct player *cp;
- long *ptrnoofchars;
- {
- if (*ptrnoofchars>0)
- {
- /* get buffer from terminal */
- read(cp->fd,cp->buf,*ptrnoofchars);
- cp->buftop=(int)(*ptrnoofchars);
- cp->bufptr=0;
- }
- }
-
- flushbuf(cp)
- register struct player *cp;
- {
- cp->buf[0]='\0';
- cp->buftop=0;
- cp->bufptr=0;
- }
-
- getchr(cp)
- register struct player *cp;
- {
- if (cp->bufptr==cp->buftop) /*is buffer empty?*/
- {
- flushbuf(cp);
- return('\0');
- } else
- return(cp->buf[cp->bufptr++]);
- }
-
-
-